<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <button>点击</button>
    <p>abc</p>
    <div class="inner"></div>
    <div class="create"></div>
    
    <script>
        //write 导致页面重绘
        document.write('<div>123</div>');
        // 页面重绘
        // var btn = document.querySelector('button');
        // btn.onclick = function(){
        //     document.write('<div>123</div>');
        // }

        //innerHTML 效率低 可采取数组拼接
        var inner = document.querySelector('.inner');
        inner.innerHTML = '<a href="#">百度</a>';
        // var arr = [];
        // for(var i = 0; i < 100; i++){
        //     arr[i] = '<a href="#">百度</a>';
        // }
        // inner.innerHTML = arr.join('');

        //createElement 效率高
        var create = document.querySelector('.create');
        var a = document.createElement('a');
        a.setAttribute('herf','#');
        a.innerHTML = '网易';
        create.appendChild(a);
    </script>
</body>
</html>